package com.gof.example.proxy;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * Created by zhiyuan on 2018/5/9 10:32.
 * haiming.fei@tongdun.cn
 */
public class Proxy implements AbstractService {

    private AbstractService abstractService = new Service();

    private void methodBefore() {
        System.out.println("方法Method()被调用，调用时间为" + new SimpleDateFormat("yyyy-M-d hh:mm:ss").format(new Date()));
    }


    @Override
    public void method() {
        methodBefore();
        abstractService.method();
        methodAfter();
    }

    private void methodAfter() {
        System.out.println("方法Method()调用成功");
    }
}
